/**
 * 
 */
package geometry;

import java.awt.geom.Ellipse2D;
import java.awt.geom.Point2D;
import java.awt.geom.Rectangle2D;

/**
 * @author Xiaohui
 * 
 */
public class Circle extends Ellipse2D.Double {

	public double radius;

	public Circle(Point2D centerPoint, double radius) {
		// super(
		// (centerPoint.getX() - radius) > 0 ? (centerPoint.getX() - radius)
		// : 0,
		// (centerPoint.getY() - radius) > 0 ? (centerPoint.getY() - radius)
		// : 0, radius * 2, radius * 2);
		super(centerPoint.getX() - radius, centerPoint.getY() - radius,
				radius * 2, radius * 2);
		this.radius = radius;
	}

	public Circle(double[] center, double radius) {
		super(center[0] - radius, center[1] - radius, radius * 2, radius * 2);
		this.radius = radius;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see java.awt.Shape#getBounds2D()
	 */
	@Override
	public Rectangle2D getBounds2D() {
		return super.getBounds2D();
	}

	public Point2D.Double getCenterP() {
		return new Point2D.Double(super.getCenterX(), super.getCenterY());
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see java.awt.geom.RectangularShape#getHeight()
	 */
	@Override
	public double getHeight() {
		return super.getHeight();
	}

	public double getRadius() {
		return this.radius;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see java.awt.geom.RectangularShape#getWidth()
	 */
	@Override
	public double getWidth() {
		return super.getWidth();
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see java.awt.geom.RectangularShape#getX()
	 */
	@Override
	public double getX() {
		return super.getX();
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see java.awt.geom.RectangularShape#getY()
	 */
	@Override
	public double getY() {
		return super.getY();
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see java.awt.geom.RectangularShape#isEmpty()
	 */
	@Override
	public boolean isEmpty() {
		return super.isEmpty();
	}

	/**
	 * Set circle center to the new point
	 * 
	 * @param point
	 */
	public void setCenter(Point2D point) {
		super.x = point.getX() - radius;
		super.y = point.getY() - radius;
	}

	/**
	 * 
	 * 
	 */
	public void setCenter(double x, double y) {
		super.x = x - radius;
		super.y = y - radius;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see java.awt.geom.RectangularShape#setFrame(double, double, double,
	 * double)
	 */
	@Override
	public void setFrame(double arg0, double arg1, double arg2, double arg3) {
		super.setFrame(arg0, arg1, arg2, arg3);

	}

}
